﻿using System;
using System.Collections.Generic;
using PrearrangedChaos.AgileZen.Service.Model;

namespace PrearrangedChaos.AgileZen.Service
{
    public interface IZenService
    {
        int PageSize { get; set; }
        string ApiKey { get; set; }

        //Get operations
        IAttachment GetAttachment(int projectId, int storyId, int attachmentId);
        IComment GetComment(int projectId, int storyId, int commentId);
        IInvite GetInvite(int projectId, int inviteId);
        IUser GetMe();
        IPhase GetPhase(int projectId, int phaseId);
        IProject GetProject(int projectId);
        IRole GetRole(int projectId, int roleId);
        IStory GetStory(int projectId, int storyId);
        ITag GetTag(int projectId, int tagId);
        ITag GetTag(int projectId, string tag);
        ITask GetTask(int projectId, int storyId, int taskId);

        //List operations
        IZenAttachmentEnumerable GetAttachments(int projectId, int storyId);
        IZenCommentEnumerable GetComments(int projectId, int storyId);
        IZenInviteEnumerable GetInvites(int projectId);
        IZenPhaseEnumerable GetPhases(int projectId);
        IZenProjectEnumerable GetProjects();
        IZenUserEnumerable GetProjectMembers(int projectId);
        IZenRoleEnumerable GetRoles(int projectId);
        IZenUserEnumerable GetRoleMembers(int projectId, int roleId);
        IZenStoryEnumerable GetStories(int projectId);
        IZenStoryEnumerable GetMyStories();
        IZenTagEnumerable GetStoryTags(int storyId);
        IZenTagEnumerable GetTags(int projectId);
        IZenStoryEnumerable GetTagStories(int projectId, int tagId);
        IZenStoryEnumerable GetTagStories(int projectId, string tag);
        IZenTaskEnumerable GetTasks(int projectId, int storyId);

        //Create operations
        IStory CreateStory(int projectId, string text, string details = null, string size = null, StoryColor color = StoryColor.Grey,
            int? phaseId = null, int? ownerId = null, DateTime? deadline = null, IEnumerable<ITag> tags = null, IEnumerable<ITask> tasks = null);
        IRole CreateRole(int projectId, string name, ApiAccess access);
        ITask CreateTask(int projectId, int storyId, string text, TaskStatus status = TaskStatus.Incomplete);
        ITag CreateTag(int projectId, string name);
        IPhase CreatePhase(int projectId, string name, string description, int? index = null, int? limit = null);
        IInvite CreateInvite(int projectId, string email, int roleId);
        IComment CreateComment(int projectId, int storyId, string text);
        IAttachment CreateAttachment(int projectId, int storyId, byte attachment);

        //Add operations
        void AddUserToRole(int projectId, int roleId, int userId);
        void AddTagToStory(int projectId, int storyId, int tagId);
        void AddUserToProject(int projectId, int userId);

        //Delete operations
        void DeleteAttachment(int projectId, int storyId, int attachmentId);
        void DeleteComment(int projectId, int storyId, int commentId);
        void DeleteInvite(int projectId, int inviteId);
        void DeletePhase(int projectId, int phaseId);
        void DeleteTag(int projectId, int tagId);
        void DeleteTask(int projectId, int storyId, int tagId);
        void DeleteRole(int projectId, int roleId);
        void DeleteStory(int projectId, int storyId);

        //Remove operations
        void RemoveUserFromProject(int projectId, int userId);
        void RemoveTagFromStory(int projectId, int storyId, int tagId);
        void RemoveUserFromRole(int projectId, int roleId, int userId);

        //Update operations
        IAttachment UpdateAttachment(IAttachmentUpdater attachment, int projectId, int storyId);
        IComment UpdateComment(ICommentUpdater comment, int projectId, int storyId);
        IPhase UpdatePhase(IPhaseUpdater phase, int projectId);
        ITag UpdateTag(ITagUpdater tag, int projectId);
        ITask UpdateTask(ITaskUpdater task, int projectId, int storyId);
        IRole UpdateRole(IRoleUpdater role, int projectId);
        IStory UpdateStory(IStoryUpdater story, int projectId);
        IProject UpdateProject(IProjectUpdater project);
    }
}